package com.example.dataView.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.dataView.common.result.R;
import com.example.dataView.pojo.MajorInfo;
import com.example.dataView.mapper.MajorInfoMapper;
import com.example.dataView.service.MajorInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 成大事
 * @since 2022-06-10 11:25:14
 */
@Slf4j
@Service
public class MajorInfoServiceImpl extends ServiceImpl<MajorInfoMapper, MajorInfo> implements MajorInfoService {

    @Resource
    private MajorInfoMapper majorInfoMapper;

    /**
     * 根据学校id获取这个学校的专业信息
     * @param schoolId   学校的id
     * @return R<Object>
     */
    @Override
    public R<Object> getMajorInfo(String schoolId) {
        try {
            List<Map<String, Object>> maps = majorInfoMapper.selectMaps(new QueryWrapper<MajorInfo>()
                    .eq("school_id", schoolId));
            return R.ok(maps);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }

}
